package me.huangxiang.data_structure_and_algorithm.common;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

public class RandomIntegerGenerator {
    public static void main(String[] args) throws IOException {
        String filePath = System.getProperty("user.dir");
        filePath += File.separator;
        filePath += "data.txt";
        System.out.println("FilePath: " + filePath);

        File file = new File(filePath);
        if (!file.exists()){
            file.createNewFile();
            System.out.println("data.txt has been created.");
        }

        FileWriter fw = new FileWriter(file);
        BufferedWriter bw = new BufferedWriter(fw);

        Random random = new Random();
        for (int i = 0; i < 100; i++){
             int randint = (int)Math.floor(random.nextDouble() * 100.0);
             bw.write(String.valueOf(randint));
             bw.newLine();
        }

        bw.close();
        fw.close();
    }
}
